package com.apabi.config;

import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

import java.util.List;

/**
 * Created by huhu on 2018/1/12.
 */
@Configuration
public class FastjsonConfiguration extends WebMvcConfigurerAdapter {


        @Override
        public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
            FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
            //自定义配置...
            FastJsonConfig config = new FastJsonConfig();
            config.setSerializerFeatures(SerializerFeature.PrettyFormat);
            //config.set ...
            converter.setFastJsonConfig(config);
            converters.add(converter);
        }

}